<?php

error_reporting(E_ALL ^ E_NOTICE);

// includes
include_once 'functions.php';
include_once 'includes.php';
includes::loadAll();

// strict messages in debug mode
if (config::getInstance()->debug) {
	error_reporting(E_ALL | E_STRICT);
}

// error handling
set_error_handler(array('error', 'handler'));

// request
$request = new request($_GET);

// begin document
$doc = document::createInstance($request);

// main contents
ob_start();
if (message::getFlash("acl")) {
	error::acl(message::getFlash("acl"));
}
if (!acl::getInstance()->checkRequest($request)) {
	message::setFlash("User access level requirements not met. Please <a href='/user/loginform'>log in</a> or upgrade your account.", "acl");
	$doc->setRedirect(document::REDIRECT_REFFERER);
} else {
	module::load($request);	
}
$doc->contents["main"] = ob_get_contents();
ob_end_clean();

// echo document
$doc->output("header");
$doc->output("body");
$doc->output("footer");
	
?>